home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Reference Guide
/
C-C++ Interactive Reference Guide.iso
/
c_ref
/
csource3
/
132_01
/
run6809.a69
< prev
next >
Wrap
Text File
|
1985-08-21
|
4KB
|
220 lines
#ASM
; +
; Runtime package for the small c compiler.
; See Dr. Dobb's Journal #48 (Sept.,1980) for
; original 8080 version and comments.
; Register conventions:
; Primary register D
; Secondary register X
; Primary byte reg. B
; Since X is not a full function arithmetic register,
; it will usually be pushed onto the hardware (S) stack
; and operations will index it off the stack pointer.
; Working storage is also allocated on the stack.
;-
ccgchar:
FCB 01FH,01 ; TFR D,X
FCB 0E6H,084H ; LD B ,X
ccsxt:
FCB 01DH ;SEX
rts
ccgint:
FCB 01FH,01 ; TFR D,X
FCB 0ECH,084H ; LDD 0,X
rts
ccpchar:
FCB 0E7H,084H ;STB ,X
rts
ccpint:
FCB 0EDH,084H ;STD ,X
rts
ccor:
FCB 034H,010H ; PSHS X
FCB 0AAH,0E0H ; ORA ,S+
FCB 0EAH,0E0H ; ORB ,S+
rts
ccxor:
FCB 034H,010H ; PSHS x
FCB 0A8H,0E0H ; EORA ,S+
FCB 0E8H,0E0H ; EORB ,S+
rts
ccand:
FCB 034H,010H ;PSHS X
FCB 0A4H,0E0H ;ANDA ,s+
FCB 0E4H,0E0H ;ANDB ,S+
rts
cccmp:
FCB 034H,006H ;PSHS D
FCB 01EH,01 ;EXG D,X
FCB 08EH,0,1 ;LDX #1
FCB 0A3H,0E1H ;SUBD ,S++
FCB 01EH,01 ;EXG D,X move 1 into D w/o affecting flags
bmi ccmp1
FCB 01CH,0FEH ;ANDCC FE clear the carry bit
rts
ccmp1:
FCB 01AH,01 ;ORCC 01 set the carry bit
rts
cceq:
bsr cccmp
beq exit
decb
exit: rts
ccne:
bsr cccmp
bne exit
decb
rts
ccgt:
FCB 01EH,01 ; EXG D,X
bsr cccmp
bcs exit
decb
rts
ccle:
bsr cccmp
beq exit
bcs exit
decb
rts
ccge:
bsr cccmp
bcc exit
decb
rts
cclt:
bsr cccmp
bcs exit
decb
rts
ccuge:
bsr ccucmp
bcc exit
decb
rts
ccult:
bsr ccucmp
bcs exit
decb
rts
ccugt:
FCB 01EH,01 ;EXG D,X
bsr ccucmp
bcs exit
decb
rts
ccule:
bsr ccucmp
beq exit
bcs exit
decb
rts
ccucmp:
FCB 034H,06 ;PSHS D
FCB 01EH,01 ;EXG D,X
FCB 08EH,01 ;LDX #1
FCB 010H,0A3H,0E1H ;CMPD 0,S++
rts
ccasr:
FCB 01EH,01 ;EXG D,X
lccasr:
asra
rorb
FCB 030H,01FH ;LEAX -1,X
bne lccasr
rts
ccasl:
FCB 01EH,01 ;EXG D,X
lccasl:
aslb
rola
FCB 030H,01FH ;LEAX -1,x
bne lccasl
rts
ccsub:
FCB 034H,06 ;PSHS D
FCB 01eH,01 ;EXG D,X
FCB 0A3H,0E1H ;SUBD ,S++
rts
cccom:
coma
comb
rts
ccneg:
coma
comb
FCB 0C3H,00,01 ;ADDD #1
rts
ccmult:
FCB 034H,016H ;PSHS X,D
clra
clrb
ccmul1:
FCB 064H,0e4H ;LSR 0,s test for multiply
FCB 066H,061H ;ROR 1,S
bcc ccmul2
FCB 0E3H,062H ;ADDD 2,S
ccmul2:
FCB 06dH,061H ; TST 1,s test for any more mults
bne ccmul3
FCB 06DH,0E4H ;TST ,S
bne ccmul3
FCB 032H,064H ;LEAS 4,s
rts
ccmul3:
FCB 068H,063H ; LSL 3,s move up the multiplicand
FCB 069H,062H ;ROL 2,S
bne ccmul1
FCB 06DH,063H ;TST 3,S
bne ccmul1
FCB 032H,064H ;LEAS 4,S
rts
ccdiv:
FCB 034H,016H ;PSHS X,D
FCB 0A8H,062H ;EORA 2,S
FCB 034H,006H ;PSHS D
clra
clrb
FCB 034H,006H ;PSHS D
FCB 06DH,064H ;TST 4,S
bpl ccdiv0
FCB 0A3H,064H ;SUBD 4.S
FCB 0EDH,064H ;STD 4,s
ccdiv0:
FCB 06DH,066H ;TST 6,S
bpl ccdiv4
clra
clrb
FCB 0A3H,066H ;SUBD 6,S
FCB 0EDH,066H ;STD 6,s
ccdiv4:
FCB 0CCH,0,010H ;LDD #16
FCB 034H,006H ;PSHS D
ccdiv1:
FCB 068H,069H ;ASL 9,S
FCB 069H,068H ;ROL 8,S
FCB 069H,063H ;ROL 3,S
FCB 069H,062H ;ROL 2,S
bne ccdiv2
FCB 0ECH,062H ;LDD 2,S
FCB 010H,0A3H,066H ;CMPD 6,S
bmi ccdiv2
FCB 06CH,069H ;INC 9,S
FCB 0ECH,062H ;LDD 2,S
FCB 0A3H,066H ;SUBD 6,S
FCB 0EDH,066H ;STD 6,S
ccdiv2:
FCB 06AH,061H ;DEC 1,S
bne ccdiv1
ccdiv3:
FCB 06DH,064H ;TST 4,S
bpl ccdivx
clra
clrb
FCB 0A3H,062H ;SUBD 2,S
FCB 032H,06AH ;LEAS A,S
ccdivx:
rts
#ENDASM
"√8├#>═{#!]═-#>*?5═#>
*K5═#╔:▒8O>*▓8═#:9■╩≥"9═æ!₧*≥3⌠3═"├ß!σ┼⌡═#±═{#┴ß├T#>╣╨>?╣╚:9╣╚y29┼>